package com.hefei.garden.other;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.handler.inter.IExcelExportServer;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

// https://blog.csdn.net/weixin_53287520/article/details/120718865
public class Main {

    public static void main(String[] args) throws Exception {
        ExcelQueryParam excelQueryParam = new ExcelQueryParam();
        excelQueryParam.setNumberOfSize(3498);
        excelQueryParam.setSheetOfSize(5000);
        ExportParams params = new ExportParams("大数据测试", "测试");
        Workbook workbook = ExcelExportUtil.exportBigExcel(params, MsgClient.class, new IExcelExportServer() {
            @Override
            public List<Object> selectListForExcelExport(Object excelQueryParam, int page) {
                ExcelQueryParam queryParam = (ExcelQueryParam) excelQueryParam;
                long numberOfSize = queryParam.getNumberOfSize();
                System.out.println(numberOfSize);
                System.out.println(page);
                System.out.println("##########################");
                return new ArrayList<>();
            }

            private String get(){
                return null;
            }

        }, excelQueryParam);
        File saveFile = new File("D:/home/excel/");
        if (!saveFile.exists()) {
            saveFile.mkdirs();
        }
        FileOutputStream fos = new FileOutputStream("D:/home/excel/ExcelExportBigData.bigDataExport.xlsx");
        workbook.write(fos);
        fos.close();
    }
}
